package com.xinfu.newproject.presenter;

import com.xinfu.newproject.bean.certifition.AddRoomBean;
import com.xinfu.newproject.bean.certifition.AddRoomBody;
import com.xinfu.newproject.callback.MyCallBack;
import com.xinfu.newproject.model.certifition.AddRoomModel;
import com.xinfu.newproject.view.IView;

import io.reactivex.disposables.Disposable;

public class AddRoomPresenter {
    private IView.IAddRoomView mIAddRoomView;

    private AddRoomModel mAddRoomModel;

    public AddRoomPresenter(IView.IAddRoomView iAddRoomView) {
        this.mIAddRoomView = iAddRoomView;
        mAddRoomModel = new AddRoomModel();
    }

    /**
     * 登录
     */
    public void addRoom() {
        mIAddRoomView.showProgress();
        AddRoomBody addRoomBody = new AddRoomBody(mIAddRoomView.header(), mIAddRoomView.projectId(), mIAddRoomView.userId(), mIAddRoomView.userName(), mIAddRoomView.roomId(), mIAddRoomView.applyName(), mIAddRoomView.applyTel(), mIAddRoomView.address(), mIAddRoomView.idType(), mIAddRoomView.imgUrl(), mIAddRoomView.applyCusName(), mIAddRoomView.applyCusTel(), mIAddRoomView.area());

        mAddRoomModel.addRoom(addRoomBody, new MyCallBack<AddRoomBean>() {
            @Override
            public void onSuccess(AddRoomBean addRoomBean) {
                mIAddRoomView.hideProgress();
                if (addRoomBean.isSuccess()) {
                    mIAddRoomView.getData(addRoomBean);
                } else {
                    mIAddRoomView.showToast(addRoomBean.getMessage());
                }
                mIAddRoomView.showToast(addRoomBean.getMessage());
            }

            @Override
            public void onError(String header, String message) {
                mIAddRoomView.hideProgress();
                mIAddRoomView.showToast(message);
            }

            @Override
            public void onDispose(Disposable disposable) {
                mIAddRoomView.closeDispose(disposable);
            }
        });


    }


//    private Map<String, String> createParaMap() {
//        Map<String, String> paraMap = new HashMap<>();
//        paraMap.put("userName", mIRegisterView.getUserName());
//        return paraMap;
//    }

}
